package com.jblv.frame.common.utils.jwt.jackjson;

import org.springframework.util.ClassUtils;

/**
 * @author happyonion.yangtao
 * @version 1.0
 * @title JsonParserFactory
 * @projectName jblv-frame
 * @packageName com.jblv.common.utils.jwt.jackjson
 * @description JsonParserFactory
 * @date Create at 2020/4/30 23:25
 * @since jdk1.8
 */
public class JsonParserFactory {
    public JsonParserFactory() {
    }

    public static JsonParser create() {
        if (ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", (ClassLoader)null)) {
            return new Jackson2JsonParser();
        } else if (ClassUtils.isPresent("org.codehaus.jackson.map.ObjectMapper", (ClassLoader)null)) {
            return new JacksonJsonParser();
        } else {
            throw new IllegalStateException("No Jackson parser found. Please add Jackson to your classpath.");
        }
    }
}